using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class ContractDetailInfo
    {
		#region Local Variable
		private Int32 _ID;
		public Int32 ID
		{
			get { return _ID; }
			set { _ID = value; }
		}
		private String _Contract;
		public String Contract
		{
			get { return _Contract; }
			set { _Contract = value; }
		}
		private Double _LimitAmt;
		public Double LimitAmt
		{
			get { return _LimitAmt; }
			set { _LimitAmt = value; }
		}
		private Double _LimitAmtOther;
		public Double LimitAmtOther
		{
			get { return _LimitAmtOther; }
			set { _LimitAmtOther = value; }
		}
		private Double _CIT;
		public Double CIT
		{
			get { return _CIT; }
			set { _CIT = value; }
		}
		private Double _VAT;
		public Double VAT
		{
			get { return _VAT; }
			set { _VAT = value; }
		}
		private String _Addendum;
		public String Addendum
		{
			get { return _Addendum; }
			set { _Addendum = value; }
		}
		private DateTime _SignDate;
		public DateTime SignDate
		{
			get { return _SignDate; }
			set { _SignDate = value; }
		}
		private DateTime _EffectiveDate;
		public DateTime EffectiveDate
		{
			get { return _EffectiveDate; }
			set { _EffectiveDate = value; }
		}
		private DateTime _ExpiryDate;
		public DateTime ExpiryDate
		{
			get { return _ExpiryDate; }
			set { _ExpiryDate = value; }
		}
		private Int32 _MCApproval;
		public Int32 MCApproval
		{
			get { return _MCApproval; }
			set { _MCApproval = value; }
		}
		private String _ActionRequired;
		public String ActionRequired
		{
			get { return _ActionRequired; }
			set { _ActionRequired = value; }
		}
		private String _Status;
		public String Status
		{
			get { return _Status; }
			set { _Status = value; }
		}
		private String _Remark1;
		public String Remark1
		{
			get { return _Remark1; }
			set { _Remark1 = value; }
		}
		private String _Remark2;
		public String Remark2
		{
			get { return _Remark2; }
			set { _Remark2 = value; }
		}
		private String _Remark3;
		public String Remark3
		{
			get { return _Remark3; }
			set { _Remark3 = value; }
		}
		private String _BudgetCode;
		public String BudgetCode
		{
			get { return _BudgetCode; }
			set { _BudgetCode = value; }
		}
		private Int32 _BudgetYear;
		public Int32 BudgetYear
		{
			get { return _BudgetYear; }
			set { _BudgetYear = value; }
		}
		private String _OrderReq;
		public String OrderReq
		{
			get { return _OrderReq; }
			set { _OrderReq = value; }
		}
		private String _YearBudgetCode;
		public String YearBudgetCode
		{
			get { return _YearBudgetCode; }
			set { _YearBudgetCode = value; }
		}
		private String _aType;
		public String aType
		{
			get { return _aType; }
			set { _aType = value; }
		}
		private Int32 _Period;
		public Int32 Period
		{
			get { return _Period; }
			set { _Period = value; }
		}
        #endregion LocalVariable
        
        #region Constructor
		public ContractDetailInfo()
		{
			_ID = -1;
			_Contract = "";
			_LimitAmt = 0;
			_LimitAmtOther = 0;
			_CIT = 0;
			_VAT = 0;
			_Addendum = "";
            _SignDate = DateTime.MinValue;
            _EffectiveDate = DateTime.MinValue;
            _ExpiryDate = DateTime.MinValue;
			_MCApproval = -1;
			_ActionRequired = "";
			_Status = "";
			_Remark1 = "";
			_Remark2 = "";
			_Remark3 = "";
			_BudgetCode = "";
			_BudgetYear = -1;
			_OrderReq = "";
			_YearBudgetCode = "";
			_aType = "";
			_Period = -1;
		}
		public ContractDetailInfo(
			Int32 ID,
			String Contract,
			Double LimitAmt,
			Double LimitAmtOther,
			Double CIT,
			Double VAT,
			String Addendum,
			DateTime SignDate,
			DateTime EffectiveDate,
			DateTime ExpiryDate,
			Int32 MCApproval,
			String ActionRequired,
			String Status,
			String Remark1,
			String Remark2,
			String Remark3,
			String BudgetCode,
			Int32 BudgetYear,
			String OrderReq,
			String YearBudgetCode,
			String aType,
			Int32 Period
			)
		{
			_ID = ID;
			_Contract = Contract;
			_LimitAmt = LimitAmt;
			_LimitAmtOther = LimitAmtOther;
			_CIT = CIT;
			_VAT = VAT;
			_Addendum = Addendum;
			_SignDate = SignDate;
			_EffectiveDate = EffectiveDate;
			_ExpiryDate = ExpiryDate;
			_MCApproval = MCApproval;
			_ActionRequired = ActionRequired;
			_Status = Status;
			_Remark1 = Remark1;
			_Remark2 = Remark2;
			_Remark3 = Remark3;
			_BudgetCode = BudgetCode;
			_BudgetYear = BudgetYear;
			_OrderReq = OrderReq;
			_YearBudgetCode = YearBudgetCode;
			_aType = aType;
			_Period = Period;
		}
		public ContractDetailInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_ID = dr["ID"] == DBNull.Value ? -1 : (Int32)dr["ID"];
				_Contract = dr["Contract"] == DBNull.Value ? "" : (String)dr["Contract"];
				_LimitAmt = dr["LimitAmt"] == DBNull.Value ? 0 : (Double)dr["LimitAmt"];
				_LimitAmtOther = dr["LimitAmtOther"] == DBNull.Value ? 0 : (Double)dr["LimitAmtOther"];
				_CIT = dr["CIT"] == DBNull.Value ? 0 : (Double)dr["CIT"];
				_VAT = dr["VAT"] == DBNull.Value ? 0 : (Double)dr["VAT"];
				_Addendum = dr["Addendum"] == DBNull.Value ? "" : (String)dr["Addendum"];

                _SignDate = dr["SignDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["SignDate"];
                _EffectiveDate = dr["EffectiveDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["EffectiveDate"];
                _ExpiryDate = dr["ExpiryDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["ExpiryDate"];

				_MCApproval = dr["MCApproval"] == DBNull.Value ? -1 : (Int32)dr["MCApproval"];
				_ActionRequired = dr["ActionRequired"] == DBNull.Value ? "" : (String)dr["ActionRequired"];
				_Status = dr["Status"] == DBNull.Value ? "" : (String)dr["Status"];
				_Remark1 = dr["Remark1"] == DBNull.Value ? "" : (String)dr["Remark1"];
				_Remark2 = dr["Remark2"] == DBNull.Value ? "" : (String)dr["Remark2"];
				_Remark3 = dr["Remark3"] == DBNull.Value ? "" : (String)dr["Remark3"];
				_BudgetCode = dr["BudgetCode"] == DBNull.Value ? "" : (String)dr["BudgetCode"];
				_BudgetYear = dr["BudgetYear"] == DBNull.Value ? -1 : (Int32)dr["BudgetYear"];
				_OrderReq = dr["OrderReq"] == DBNull.Value ? "" : (String)dr["OrderReq"];
				_YearBudgetCode = dr["YearBudgetCode"] == DBNull.Value ? "" : (String)dr["YearBudgetCode"];
				_aType = dr["aType"] == DBNull.Value ? "" : (String)dr["aType"];
				_Period = dr["Period"] == DBNull.Value ? -1 : (Int32)dr["Period"];
			}
		}
        public ContractDetailInfo(DataRow dr)
        {
            if (dr != null)
            {
                _ID = dr["ID"] == DBNull.Value ? -1 : (Int32)dr["ID"];
                _Contract = dr["Contract"] == DBNull.Value ? "" : (String)dr["Contract"];
                _LimitAmt = dr["LimitAmt"] == DBNull.Value ? 0 : (Double)dr["LimitAmt"];
                _LimitAmtOther = dr["LimitAmtOther"] == DBNull.Value ? 0 : (Double)dr["LimitAmtOther"];
                _CIT = dr["CIT"] == DBNull.Value ? 0 : (Double)dr["CIT"];
                _VAT = dr["VAT"] == DBNull.Value ? 0 : (Double)dr["VAT"];
                _Addendum = dr["Addendum"] == DBNull.Value ? "" : (String)dr["Addendum"];
                _SignDate = dr["SignDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["SignDate"];
                _EffectiveDate = dr["EffectiveDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["EffectiveDate"];
                _ExpiryDate = dr["ExpiryDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["ExpiryDate"];
                _MCApproval = dr["MCApproval"] == DBNull.Value ? -1 : (Int32)dr["MCApproval"];
                _ActionRequired = dr["ActionRequired"] == DBNull.Value ? "" : (String)dr["ActionRequired"];
                _Status = dr["Status"] == DBNull.Value ? "" : (String)dr["Status"];
                _Remark1 = dr["Remark1"] == DBNull.Value ? "" : (String)dr["Remark1"];
                _Remark2 = dr["Remark2"] == DBNull.Value ? "" : (String)dr["Remark2"];
                _Remark3 = dr["Remark3"] == DBNull.Value ? "" : (String)dr["Remark3"];
                _BudgetCode = dr["BudgetCode"] == DBNull.Value ? "" : (String)dr["BudgetCode"];
                _BudgetYear = dr["BudgetYear"] == DBNull.Value ? -1 : (Int32)dr["BudgetYear"];
                _OrderReq = dr["OrderReq"] == DBNull.Value ? "" : (String)dr["OrderReq"];
                _YearBudgetCode = dr["YearBudgetCode"] == DBNull.Value ? "" : (String)dr["YearBudgetCode"];
                _aType = dr["aType"] == DBNull.Value ? "" : (String)dr["aType"];
                _Period = dr["Period"] == DBNull.Value ? -1 : (Int32)dr["Period"];
            }
        }
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblContractDetail");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("ID", typeof(Int32)),
				new DataColumn("Contract", typeof(String)),
				new DataColumn("LimitAmt", typeof(Double)),
				new DataColumn("LimitAmtOther", typeof(Double)),
				new DataColumn("CIT", typeof(Double)),
				new DataColumn("VAT", typeof(Double)),
				new DataColumn("Addendum", typeof(String)),
				new DataColumn("SignDate", typeof(DateTime)),
				new DataColumn("EffectiveDate", typeof(DateTime)),
				new DataColumn("ExpiryDate", typeof(DateTime)),
				new DataColumn("MCApproval", typeof(Int32)),
				new DataColumn("ActionRequired", typeof(String)),
				new DataColumn("Status", typeof(String)),
				new DataColumn("Remark1", typeof(String)),
				new DataColumn("Remark2", typeof(String)),
				new DataColumn("Remark3", typeof(String)),
				new DataColumn("BudgetCode", typeof(String)),
				new DataColumn("BudgetYear", typeof(Int32)),
				new DataColumn("OrderReq", typeof(String)),
				new DataColumn("YearBudgetCode", typeof(String)),
				new DataColumn("aType", typeof(String)),
				new DataColumn("Period", typeof(Int32))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["ID"] = _ID;
			row["Contract"] = _Contract;
			row["LimitAmt"] = _LimitAmt;
			row["LimitAmtOther"] = _LimitAmtOther;
			row["CIT"] = _CIT;
			row["VAT"] = _VAT;
			row["Addendum"] = _Addendum;
			row["SignDate"] = _SignDate;
			row["EffectiveDate"] = _EffectiveDate;
			row["ExpiryDate"] = _ExpiryDate;
			row["MCApproval"] = _MCApproval;
			row["ActionRequired"] = _ActionRequired;
			row["Status"] = _Status;
			row["Remark1"] = _Remark1;
			row["Remark2"] = _Remark2;
			row["Remark3"] = _Remark3;
			row["BudgetCode"] = _BudgetCode;
			row["BudgetYear"] = _BudgetYear;
			row["OrderReq"] = _OrderReq;
			row["YearBudgetCode"] = _YearBudgetCode;
			row["aType"] = _aType;
			row["Period"] = _Period;
			return row;
		}
        #endregion InitTable
    }
}
